package com.oktest.measure

import android.content.Intent
import android.os.Bundle
import com.oktest.measure.ui.fragment.work.FeedbackFragment
import me.yokeyword.fragmentation.SupportActivity
import me.yokeyword.fragmentation.anim.DefaultNoAnimator
import me.yokeyword.fragmentation.anim.FragmentAnimator

class MainActivity : SupportActivity() {

    private val mainFragment by lazy {
        MainFragment.newInstance()
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_root)
        findFragment(MainFragment::class.java) ?: loadRootFragment(
            R.id.fl_container,
            mainFragment
        )
    }

    /**
     * 默认动画
     */
    override fun onCreateFragmentAnimator(): FragmentAnimator {
        return DefaultNoAnimator()
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        mainFragment.onFragmentResult(requestCode, resultCode, data?.extras)
    }

    override fun onBackPressedSupport() {
        //点击返回按钮应用退到后台
        moveTaskToBack(!isTaskRoot)
    }
}